/* ============================================================
   MAP STYLES
   ============================================================ */


/* ============================================================
   POPUP
   ============================================================ */

.ol-popup {
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    pointer-events: none;
    direction: rtl;
}

.popup-card {
    direction: rtl;
    text-align: right;
    padding: 28px 24px 24px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    font-family: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
    color: #ffffff;
    min-width: 260px;
    max-width: 360px;
    position: relative;
}

.popup-line {
    width: 50px;
    height: 3px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 2px;
    margin-bottom: 16px;
}

.popup-title {
    font-size: 20px;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 4px;
}

.popup-label {
    font-size: 13px;
    font-weight: 300;
    opacity: 0.7;
    margin-bottom: 4px;
}

.popup-value {
    font-size: 14px;
    font-weight: 400;
    opacity: 0.9;
    margin-bottom: 14px;
    line-height: 1.5;
}

.popup-separator {
    height: 1px;
    background: rgba(255, 255, 255, 0.2);
    margin: 12px 0 14px;
}

.popup-info div {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 6px;
}

.popup-arrow {
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid;
}


/* ============================================================
   MAP CONTAINERS
   ============================================================ */

#full-map-container {
    position: relative;
    width: 100%;
    min-height: 500px;
    height: 500px;

    padding: 0 !important;
    margin: 0 auto;

    box-sizing: border-box;
    overflow: hidden;

    border-radius: 16px;
}

#full-map {
    position: absolute !important;

    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;

    width: 100% !important;
    height: 100% !important;

    min-height: 0 !important;

    margin: 0 !important;
    padding: 0 !important;

    display: block;

    background: #e8edf3;

    box-sizing: border-box;

    border-radius: inherit;

    overflow: hidden;
}


/* ============================================================
   MINI MAP
   ============================================================ */

#mini-map {
    position: absolute !important;

    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;

    width: 100% !important;
    height: 100% !important;

    min-width: 0 !important;
    min-height: 0 !important;

    margin: 0 !important;
    padding: 0 !important;

    display: block;

    box-sizing: border-box;

    overflow: hidden;

    border-radius: inherit;
}


/* ============================================================
   OPENLAYERS VIEWPORT
   ============================================================ */

#full-map .ol-viewport,
#mini-map .ol-viewport {

    position: absolute !important;

    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;

    width: 100% !important;
    height: 100% !important;

    min-width: 0 !important;
    min-height: 0 !important;

    margin: 0 !important;
    padding: 0 !important;

    box-sizing: border-box;

    overflow: hidden !important;

    border-radius: inherit;
}


/* ============================================================
   OPENLAYERS LAYERS
   ============================================================ */

#full-map .ol-layers,
#mini-map .ol-layers {

    position: absolute !important;

    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;

    width: 100% !important;
    height: 100% !important;

    margin: 0 !important;
    padding: 0 !important;

    box-sizing: border-box;
}


/*
   Individual OpenLayers layers
*/

#full-map .ol-layer,
#mini-map .ol-layer {

    position: absolute !important;

    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;

    width: 100% !important;
    height: 100% !important;

    margin: 0 !important;
    padding: 0 !important;

    box-sizing: border-box;
}


/* ============================================================
   OPENLAYERS CANVAS / IMAGES
   ============================================================ */

#full-map .ol-layer canvas,
#mini-map .ol-layer canvas {

    display: block !important;

    position: absolute !important;

    margin: 0 !important;
    padding: 0 !important;

    max-width: none !important;
    max-height: none !important;
}


#full-map .ol-layer img,
#mini-map .ol-layer img {

    display: block !important;

    margin: 0 !important;
    padding: 0 !important;

    max-width: none !important;
    max-height: none !important;
}


/* ============================================================
   REMOVE POSSIBLE INLINE / DEFAULT SPACING
   ============================================================ */

#full-map *,
#mini-map * {
    box-sizing: border-box;
}


/* ============================================================
   MAP CONTROLS
   ============================================================ */

.ol-control button {
    min-width: 44px !important;
    min-height: 44px !important;
    font-size: 1.2rem !important;
}


/* ============================================================
   FILTER PANEL
   ============================================================ */

.filter-panel {

    position: absolute;

    top: 10px;
    right: 10px;

    width: 280px;

    max-height: calc(100% - 20px);

    overflow-y: auto;

    background: white;

    border-radius: 12px;

    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);

    z-index: 20;

    font-family: 'Vazirmatn', 'Inter', sans-serif;

    display: flex;
    flex-direction: column;

    transition:
        transform 0.3s ease,
        opacity 0.3s ease;

    transform: translateX(0);

    opacity: 1;

    box-sizing: border-box;
}


.filter-panel.hidden {

    transform: translateX(calc(100% + 20px));

    opacity: 0;

    pointer-events: none;
}


html[lang="en"] .filter-panel,
.filter-panel[dir="ltr"] {

    right: auto;
    left: 10px;
}


html[lang="en"] .filter-panel.hidden,
.filter-panel[dir="ltr"].hidden {

    transform: translateX(calc(-100% - 20px));
}


/* ============================================================
   FILTER HEADER
   ============================================================ */

.filter-header {

    display: flex;

    justify-content: space-between;

    align-items: center;

    padding: 14px 16px;

    border-bottom: 1px solid #e2e8f0;

    font-weight: 600;

    font-size: 0.95rem;

    flex-shrink: 0;

    background: white;

    border-radius: 12px 12px 0 0;
}


/* ============================================================
   FILTER BUTTONS
   ============================================================ */

.filter-buttons {

    display: flex;

    gap: 8px;
}


.filter-btn-select,
.filter-btn-clear {

    font-size: 0.75rem;

    padding: 4px 10px;

    border-radius: 6px;

    border: none;

    cursor: pointer;

    font-family: inherit;
}


.filter-btn-select {

    background: #2563eb;

    color: white;
}


.filter-btn-clear {

    background: #f1f5f9;

    color: #475569;
}


/* ============================================================
   FILTER ITEMS
   ============================================================ */

.filter-panel .filter-item {

    display: flex;

    align-items: center;

    gap: 10px;

    padding: 10px 16px;

    cursor: pointer;

    transition: background 0.2s;

    flex-shrink: 0;

    position: relative;
}


.filter-item:hover {

    background: #f8fafc;
}


/* ============================================================
   FILTER COLOR DOT
   ============================================================ */

.filter-color-dot {

    width: 12px;
    height: 12px;

    border-radius: 50%;

    flex-shrink: 0;
}


/* ============================================================
   FILTER CHECKBOX
   ============================================================ */

.filter-checkbox {

    flex-shrink: 0;

    width: 16px;
    height: 16px;

    cursor: pointer;
}


/* ============================================================
   FILTER LABEL
   ============================================================ */

.filter-label {

    flex: 1;

    min-width: 0;

    font-size: 0.88rem;

    line-height: 1.35;

    display: -webkit-box;

    -webkit-line-clamp: 2;

    -webkit-box-orient: vertical;

    overflow: hidden;

    text-overflow: ellipsis;

    cursor: pointer;

    position: relative;
}


/* ============================================================
   FILTER LABEL TOOLTIP
   ============================================================ */

/*
   The complete project type is stored in the title attribute
   by map.js.

   This custom tooltip appears when the user hovers/focuses
   the truncated project type.

   It is intentionally wider than the filter label so that
   long Persian/English project names can be read completely.
*/

.filter-label[title]::after {

    content: attr(title);

    position: absolute;

    right: 0;

    bottom: calc(100% + 8px);

    width: max-content;

    max-width: 240px;

    min-width: 120px;

    padding: 8px 11px;

    background: #1e293b;

    color: #ffffff;

    border-radius: 7px;

    font-family: 'Vazirmatn', 'Inter', sans-serif;

    font-size: 0.78rem;

    font-weight: 400;

    line-height: 1.5;

    text-align: right;

    white-space: normal;

    word-break: normal;

    overflow-wrap: break-word;

    box-shadow: 0 5px 18px rgba(0, 0, 0, 0.22);

    z-index: 1000;

    pointer-events: none;

    opacity: 0;

    visibility: hidden;

    transform: translateY(4px);

    transition:
        opacity 0.18s ease,
        transform 0.18s ease,
        visibility 0.18s ease;
}


/*
   Small arrow below the tooltip.
*/

.filter-label[title]::before {

    content: '';

    position: absolute;

    right: 14px;

    bottom: calc(100% + 2px);

    width: 0;
    height: 0;

    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #1e293b;

    z-index: 1001;

    pointer-events: none;

    opacity: 0;

    visibility: hidden;

    transform: translateY(4px);

    transition:
        opacity 0.18s ease,
        transform 0.18s ease,
        visibility 0.18s ease;
}


/*
   Show tooltip on desktop hover.
*/

.filter-label[title]:hover::after,
.filter-label[title]:hover::before {

    opacity: 1;

    visibility: visible;

    transform: translateY(0);
}


/*
   Also show tooltip when the label receives keyboard focus.
*/

.filter-label[title]:focus::after,
.filter-label[title]:focus::before {

    opacity: 1;

    visibility: visible;

    transform: translateY(0);
}


/* ============================================================
   FILTER COUNT
   ============================================================ */

.filter-count {

    font-size: 0.8rem;

    color: #64748b;

    flex-shrink: 0;
}


html[lang="en"] .filter-label {

    font-family: 'Inter', sans-serif;
}


html[lang="en"] .filter-label[title]::after {

    text-align: left;

    font-family: 'Inter', sans-serif;
}


/* ============================================================
   FILTER TOOLTIP - LTR POSITION
   ============================================================ */

html[lang="en"] .filter-label[title]::after,
.filter-panel[dir="ltr"] .filter-label[title]::after {

    right: auto;

    left: 0;

    text-align: left;
}


html[lang="en"] .filter-label[title]::before,
.filter-panel[dir="ltr"] .filter-label[title]::before {

    right: auto;

    left: 14px;
}


/* ============================================================
   FILTER TOOLTIP - MOBILE
   ============================================================ */

/*
   JavaScript adds .show-tooltip to the filter item
   when the user taps the project type.
*/

.filter-item.show-tooltip {
    z-index: 1000;
}


/*
   IMPORTANT:
   The normal label uses overflow:hidden so long project
   names can be truncated.

   When the tooltip is active, allow the pseudo-element
   to escape the label's box.
*/

.filter-item.show-tooltip .filter-label {
    overflow: visible;
}


.filter-item.show-tooltip .filter-label::after,
.filter-item.show-tooltip .filter-label::before {

    opacity: 1;

    visibility: visible;

    transform: translateY(0);
}


/* ============================================================
   MOBILE POSITIONING
   ============================================================ */

@media (max-width: 768px) {

    .filter-label[title]::after {

        max-width: 200px;

        width: max-content;

        min-width: 120px;

        white-space: normal;

        text-align: right;

        right: 0;

        bottom: calc(100% + 8px);

        z-index: 1001;
    }

    .filter-label[title]::before {

        right: 14px;

        bottom: calc(100% + 2px);

        z-index: 1002;
    }

}



/* ============================================================
   FILTER TOGGLE BUTTON
   ============================================================ */

.filter-toggle {

    position: absolute;

    bottom: 12px;
    right: 12px;

    background: white;

    border: none;

    border-radius: 8px;

    padding: 10px 14px;

    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);

    cursor: pointer;

    z-index: 25;

    font-size: 16px;

    color: #2563eb;

    display: flex !important;

    align-items: center;

    gap: 6px;

    transition: all 0.2s ease;

    font-family: 'Inter', 'Vazirmatn', sans-serif;
}


.filter-toggle:hover {

    background: #f0f4ff;

    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.2);
}


.filter-toggle span {

    font-size: 13px;

    font-weight: 600;

    color: #2563eb;
}


html[lang="en"] .filter-toggle,
.filter-panel[dir="ltr"] .filter-toggle {

    right: auto;

    left: 12px;
}


/* ============================================================
   MAP Z-INDEX
   ============================================================ */

#full-map-container,
.map-section,
.map-container {

    position: relative;

    z-index: 1;

    isolation: isolate;
}


/* ============================================================
   NAVBAR
   ============================================================ */

.header {

    position: fixed !important;

    z-index: 9999 !important;
}


/* ============================================================
   MAP SECTIONS
   ============================================================ */

.hero,
.map-section,
#experience-map,
#full-map-container,
#hero-map-wrapper,
.hero-image-box,
.hero-mini-map,
#mini-map,
#full-map {

    position: relative;

    z-index: 1 !important;
}


/*
   Do NOT force random z-index values on
   OpenLayers internal elements.
*/

.ol-viewport,
.ol-layers,
.ol-layer {

    z-index: auto;
}